package com.fanrenqiji.modules.sys.dao;

import com.fanrenqiji.common.persistence.BaseDao;
import com.fanrenqiji.common.persistence.BaseDaoImpl;
import com.fanrenqiji.modules.sys.entity.NotifyRecord;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

public interface NotifyRecordDao extends NotifyRecordDaoCustom,
        CrudRepository<NotifyRecord, Long> {

	@Modifying
	@Query("delete NotifyRecord where notify.id = ?1 ")
	void deleteByNotifyId(Long id);

	@Query("from NotifyRecord where notify.id = ?1 and user.id=?2")
	NotifyRecord findByNotifyIdAndUserId(Long notifyId, Long userId);

	@Modifying
	@Query("update NotifyRecord set delFlag='" + NotifyRecord.DEL_FLAG_DELETE
			+ "' where id = ?1  ")
	void fakeDeleteByNotifyId(Long id);
}


interface NotifyRecordDaoCustom extends BaseDao<NotifyRecord> {
}

@Repository
class NotifyRecordDaoImpl extends BaseDaoImpl<NotifyRecord> implements
		NotifyRecordDaoCustom {

}